package ch.zbw.pra.sysventory.application.controller;

import java.io.Serializable;
import java.util.List;

import ch.zbw.pra.sysventory.dataaccess.dataAccessObject.ScanversionDataAccessObject;
import ch.zbw.pra.sysventory.model.Scanversion;

/**
 * Controller für das Scanversion Archive Panel
 * 
 * @author Ralph Koster
 */

public class ScanversionArchivePanelController implements Serializable {

	private static final long serialVersionUID = 7157490786829975988L;
	
	private ScanversionDataAccessObject scanversionDataAccessObject;
	private List<Scanversion> scanversions;
	
	public ScanversionArchivePanelController() {
		this.scanversionDataAccessObject = new ScanversionDataAccessObject();
	}
	
	public List<Scanversion> loadScanversions() {
		scanversions = scanversionDataAccessObject.getAllScanversionsFromDataaccess();
		return scanversions;
	}

	public Scanversion getScanversionById(String scanversionId) {
		Scanversion scanversion = new Scanversion();
		if(null != scanversions && scanversions.size() != 0) {
			for(Scanversion tempScanversion : scanversions) {
				if(scanversionId.equals(String.valueOf(tempScanversion.getId()))) {
					scanversion = tempScanversion;
				}
			}
		}
		return scanversion;
	}

}
